//package com.jumi.microservice.service;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.jumi.microservice.common.base.dto.ResponseResult;
//import com.jumi.microservice.common.constant.DelFlag;
//import com.jumi.microservice.common.page.TableDataInfo;
//import com.jumi.microservice.common.utils.DateUtil;
//import com.jumi.microservice.dto.wallet.api.*;
//import com.jumi.microservice.enumerate.WaitIncomeStatusEnum;
//import com.jumi.microservice.enumerate.WalletTypeEnum;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.math.BigDecimal;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @author wangjingdao
// * 收益明细
// */
//@Service
//public class UserWalletService {
//
//    @Resource
//    UserWaitIncomeMapper userWaitIncomeMapper;
//
//
//    public TableDataInfo<IncomeDetailsResponse> getIncomeList(IncomeDetailsRequest request) {
//        QueryWrapper<UserWaitIncome> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("delFlag", DelFlag.NORMAL);
//        queryWrapper.eq("incomeStatus", request.getIncomeStatus());
//        queryWrapper.eq("type", request.getType());
//        queryWrapper.eq("userId", request.getUid());
//        IPage<UserWaitIncome> page = new Page<>(request.getPageSize(), request.getPageNum());
//        page = userWaitIncomeMapper.selectPage(page, queryWrapper);
//        //订单id
//        List<Long> orderId = page.getRecords().stream().map(UserWaitIncome::getOrderId).collect(Collectors.toList());
//        /**
//         * 根据订单号 获取 商品名称 跟 用户id  根据用户id 查询出头像全部加到 IncomeListResponse 里面 然后List 返回出去
//         */
//        return null;
//    }
//
//    /**
//     * 累计总收益
//     *
//     * @return
//     */
//    public ResponseResult<TotalRevenueResponse> getTotalRevenue(TotalRevenueRequest request) {
//        request.setUid(1L);
//        ResponseResult<TotalRevenueResponse> totalRevenueResponseResponseResult = new ResponseResult<>();
//        TotalRevenueResponse totalRevenueResponse = new TotalRevenueResponse();
//        CumulativeRevenueResponse cumulativeRevenueResponse = new CumulativeRevenueResponse();
//        QueryWrapper<UserWaitIncome> queryWrapper = new QueryWrapper<>();
//        //带到账
//        BigDecimal cumulativeRevenue = userWaitIncomeMapper.waitIncomeByUserId(request.getUid(), WaitIncomeStatusEnum.NO_INCOME.getCode());
////        可提现
//        BigDecimal withdrawal = userWaitIncomeMapper.waitIncomeByUserId(request.getUid(), WaitIncomeStatusEnum.YES_INCOME.getCode());
////        省下...
////        留位置
//        cumulativeRevenueResponse.setReceivedAmount(cumulativeRevenue);
//        cumulativeRevenueResponse.setWithdrawalAmount(withdrawal);
//
//        //设置累计总收益
//        totalRevenueResponse.setCumulativeRevenueResponse(cumulativeRevenueResponse);
//        //今日收益
//        RevenueResponse revenueResponse = new RevenueResponse();
//        //推广收益
//        BigDecimal promotionAmount = userWaitIncomeMapper.getAmountByTypeAndTime(WalletTypeEnum.SPREAD_IN.getCode(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        //平台奖励
//        BigDecimal platformReward = userWaitIncomeMapper.getAmountByTypeAndTime(WalletTypeEnum.ORDER_IN.getCode(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        revenueResponse.setPromotionIncome(promotionAmount);
//        revenueResponse.setPlatformReward(platformReward);
//        //成交订单
//        //成交金额
//        //邀请注册
//        totalRevenueResponse.setRevenueResponse(revenueResponse);
//        //设置昨日收益
//        //昨日时间
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        Calendar calendar = Calendar.getInstance();
//        Date date = null;
//        try {
//            date = sdf.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        calendar.setTime(date);
//        int day = calendar.get(Calendar.DATE);
//        //                      此处修改为+1则是获取后一天
//        calendar.set(Calendar.DATE, day - 1);
//
//        String lastDay = sdf.format(calendar.getTime());
//        //昨日推广收益
//        BigDecimal yesterdayPromotionAmount = userWaitIncomeMapper.getAmountByTypeAndTime(WalletTypeEnum.SPREAD_IN.getCode(), lastDay);
//        //昨日平台奖励
//        BigDecimal yesterdayPlatformReward = userWaitIncomeMapper.getAmountByTypeAndTime(WalletTypeEnum.ORDER_IN.getCode(), lastDay);
//        //成交订单
//        //成交金额
//        //邀请注册
//        //设置昨日收益
//        //昨日时间
//        RevenueResponse yesterdayRevenueResponse = new RevenueResponse();
//        yesterdayRevenueResponse.setPromotionIncome(yesterdayPromotionAmount);
//        yesterdayRevenueResponse.setPlatformReward(yesterdayPlatformReward);
//        totalRevenueResponse.setYesterdayRevenueResponse(yesterdayRevenueResponse);
//        //七天前
//        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        calendar = Calendar.getInstance();
//        try {
//            date = sdf.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        calendar.setTime(date);
//        day = calendar.get(Calendar.DATE);
//        //                      此处修改为+1则是获取后一天
//        calendar.set(Calendar.DATE, day - 7);
//        String sevenDay = sdf.format(calendar.getTime());
//        //推广
//        BigDecimal sevenDayPromotionAmount = userWaitIncomeMapper.getAmountByTypeAndTwoTimes(WalletTypeEnum.SPREAD_IN.getCode(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), sevenDay);
//        //平台
//        BigDecimal sevenDayPlatformReward = userWaitIncomeMapper.getAmountByTypeAndTwoTimes(WalletTypeEnum.ORDER_IN.getCode(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), sevenDay);
//        //成交订单
//        //成交金额
//        //邀请注册
//        RevenueResponse sevenDayRevenueResponse = new RevenueResponse();
//        sevenDayRevenueResponse.setPromotionIncome(sevenDayPromotionAmount);
//        sevenDayRevenueResponse.setPlatformReward(sevenDayPlatformReward);
//        totalRevenueResponse.setSevenDayRevenueResponse(sevenDayRevenueResponse);
//        //三十天内
//        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        calendar = Calendar.getInstance();
//        try {
//            date = sdf.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        calendar.setTime(date);
//        day = calendar.get(Calendar.DATE);
//        //                      此处修改为+1则是获取后一天
//        calendar.set(Calendar.DATE, day - 30);
//        String thirtyDay = sdf.format(calendar.getTime());
//        //推广
//        BigDecimal thirtyDayPromotionAmount = userWaitIncomeMapper.getAmountByTypeAndTwoTimes(WalletTypeEnum.SPREAD_IN.getCode(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), thirtyDay);
//        //平台
//        BigDecimal thirtyDayPlatformReward = userWaitIncomeMapper.getAmountByTypeAndTwoTimes(WalletTypeEnum.ORDER_IN.getCode(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), thirtyDay);
//        RevenueResponse thirtyDayRevenueResponse = new RevenueResponse();
//        thirtyDayRevenueResponse.setPromotionIncome(thirtyDayPromotionAmount);
//        thirtyDayRevenueResponse.setPlatformReward(thirtyDayPlatformReward);
//        totalRevenueResponse.setThirtyDayRevenueResponse(thirtyDayRevenueResponse);
//        totalRevenueResponseResponseResult.setData(totalRevenueResponse);
//        return totalRevenueResponseResponseResult;
//
//    }
//
//    public static void main(String[] args) {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        Calendar calendar = Calendar.getInstance();
//        Date date = null;
//        try {
//            date = sdf.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        calendar.setTime(date);
//        int day = calendar.get(Calendar.DATE);
//        //                      此处修改为+1则是获取后一天
//        calendar.set(Calendar.DATE, day - 7);
//
//        String lastDay = sdf.format(calendar.getTime());
//        System.out.println(lastDay);
//    }
//}
